package NewTmas.Listeners;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;

/**
* Created by IntelliJ IDEA.
* User: jhauser
* Date: Jun 24, 2011
* Time: 5:42:57 PM
 Getting the selected window on the front/top of the DesktopPane
 */
public class WindowFocusListener implements ActionListener
{
    private final JInternalFrame internalFrame;

    public WindowFocusListener(JInternalFrame internalFrame)
    {
        this.internalFrame = internalFrame;
    }

    public void actionPerformed(ActionEvent e)
    {
        try
        {
            internalFrame.setSelected(true);
            internalFrame.toFront();
        } catch (PropertyVetoException e1)
        {
            e1.printStackTrace();
        }

    }
}
